package com.ldzy.controller;

import com.ldzy.pojo.Cake;
import com.ldzy.service.ICakeService;
import com.ldzy.utilts.RespUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/cake")
public class CakeController {
    @Resource
    ICakeService iCakeService;
    @GetMapping("findHou")
    public RespUtil findHou(){
        return  iCakeService.findHou();
    }
    @PostMapping("/search")
    public  RespUtil search(@RequestBody Cake cake){
        return  iCakeService.search(cake);
    }
    @GetMapping("/type")
    public  RespUtil type(){
        return  iCakeService.type();
    }
    @PostMapping("/findByType")
    public  RespUtil findByType(@RequestBody Cake cake){
        return  iCakeService.findByType(cake);
    }
    @PostMapping("/findById")
    public  RespUtil findById(@RequestBody Cake cake){
        if (iCakeService.getById(cake.getId())!=null)
            return  RespUtil.success(iCakeService.getById(cake.getId()));
        return RespUtil.error();
    }
    @GetMapping("/findHouSex")
    public  RespUtil findHouSex(){
        return  iCakeService.findHouSex();
    }

}
